package com.tepth.maintenancesystem.untils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import android.os.Environment;

public class FileUtils {
	public static File updateDir = null;
	public static File updateFile = null;

	/***
	 * 
	 */
	public static void createFile(String name) {
		if (Environment.MEDIA_MOUNTED.equals(Environment
				.getExternalStorageState())) {
			updateDir = new File(Environment.getExternalStorageDirectory()
					+ "/" + "Tepth");
			updateFile = new File(updateDir + "/" + name + ".apk");

			if (!updateDir.exists()) {
				updateDir.mkdirs();
			}
			if (!updateFile.exists()) {
				try {
					updateFile.createNewFile();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}

	/**
	 * 获取NFC MAC地址文件
	 * @param filename
	 * @return
	 */
	public static String getNFC_MAC_File(String filename){
		String str = "";
		try{
			File urlFile = new File(filename);
			InputStreamReader isr = new InputStreamReader(new FileInputStream(urlFile));
			BufferedReader br = new BufferedReader(isr);
			String mimeTypeLine;
			while ((mimeTypeLine = br.readLine()) != null) {
				str = mimeTypeLine;
				break;
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return str;
	}

//	/**
//	 * 获取内置SD卡路径
//	 * @return
//	 */
//	public static String getInnerSDCardPath() {
//		return Environment.getExternalStorageDirectory().getPath();
//	}
}
